package com.test.lixiang.lixiangtest;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.wenming.library.LogReport;

public class SplashActivity extends FragmentActivity {
    private Button mbutton;
    private ViewPager mViewPager;

    private int[] images = {R.drawable.newer01, R.drawable.newer02, R.drawable.newer03, R.drawable.newer04};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        initGuideGallery();

        LogReport.getInstance().upload(this);
    }
//    private void testUIThreadException() {
//        String string = null;
//        char[] chars = string.toCharArray();
//    }
    private void initGuideGallery() {

        mViewPager = (ViewPager) findViewById(R.id.pager);
        //pager.setVisibility(View.VISIBLE);
        // adapter = new GalleryPagerAdapter();
        mViewPager.setAdapter(mPagerAdapter);
    }

    PagerAdapter mPagerAdapter = new PagerAdapter() {
        @Override
        public int getCount() {
            return images.length;
        }

        @NonNull
        @Override
        public Object instantiateItem(@NonNull ViewGroup container, int position) {
            ImageView item = new ImageView(SplashActivity.this);
            item.setScaleType(ImageView.ScaleType.CENTER_CROP);
            item.setImageResource(images[position]);
            container.addView(item);
            return item;
        }

        @Override
        public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
            container.removeView((View) object);
        }

        @Override
        public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
            return view == object;
        }

    };


}
